/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.thingsgrid.device.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.thingsgrid.device.entity.Function;
import com.thingsgrid.device.entity.Product;
import com.thingsgrid.device.entity.ProductType;
import com.thingsgrid.device.entity.Topic;
import com.thingsgrid.device.vo.ProductVO;
import org.springframework.web.bind.annotation.RequestParam;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;

/**
 *  服务类
 *
 * @author BladeX
 * @since 2019-08-19
 */
public interface IProductService  {
	/**
	 * 产品新增
	 */
	boolean saveProduct(Product product);

	/**
	 * 产品修改
	 */
	boolean updateProduct(Product product);
	/**
	 * 根据Id产品信息
	 */
	Product findProductById(String productId);
	/**
	 * 查找所有产品信息
	 */
	List<Product> findAll();
	/**
	 * 分页查找
	 * @return
	 */
	HashMap<String, Object> findAll(Integer current, Integer size, String productName,String productTypeId, String startTime,
                                    String endTime, Integer isPublish);
	/**
	 * 增加topicItem
	 */
	void  addTopicItem(String productId, String topicClassName);
	/**
	 * del topicItem
	 */
	void removeTopicItem(String productId, String topicId);
	/**
	 *
	 */
	void addSubscribeTopicItem(String productId, String topicClassName);

	void removeSubscribeTopicItem(String productId, String topicId);
	/**
	 * 显示对应产品的topic类
	 */
	List<Topic> listTopicItems(String productId);
	/**
	 * 显示对应产品的subscribe topic类
	 */
	List<Topic> listSubscribeTopicItems(String productId);
	/**
	 * 根据productId插入physicalId
	 */
	void addPhysical(String productId, String physicalModelId);
	/**
	 * 根据productId physicalModelId 删除physicalId
	 */
	void removePhysical(String productId, String physicalModelId);

	/**
	 * 根据productId找physicalId
	 */
	String  getPhysicalId(String productId);
	/**
	 *
	 */
	List<Function> getFunctionbyPhysicalModelId(String physicalModelId);
	/**
	 * 根据条件查
	 */
	List<Product> selectByCondition(String productName, String productType, Timestamp beginTime, Timestamp endTime,
                                    Integer isPublish);
	/**
	 * add 2019.08.28
	 * product和topic两表联查
	 */
	Object findProductAndTopic();
	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param product
	 * @return
	 */
	IPage<ProductVO> selectProductPage(IPage<ProductVO> page, ProductVO product);

	/**
	 *说明：产品取消发布或删除产品
	 *@author 陈学栋
	 *@since 2019/9/20 15:29
	 */
	long cancelPublishOrDelete(String productId);

	/**
	 * 说明：查询所有产品类型
	 * @author 陈学栋
	 * @since 2019/10/11 15:28
	 */
	List<ProductType> getProductType();

	/**
	 * 说明：查询一个产品类型
	 * @author 陈学栋
	 * @since 2019/10/11 15:28
	 */
	 ProductType findOneProductType(String productTypeId);
	/**
	 * 说明：产品发布
	 * @author 陈学栋
	 * @since 2019/10/14 15:51
	 */
    long productPublish(String productId);

	/**
	 * 说明：添加产品的topic
	 * @author 陈学栋
	 * @since 2019/10/14 15:52
	 */
	boolean addProductTopic(String productId, Topic[] topic);



	/**
	 * 说明：删除产品的topic
	 * @author 陈学栋
	 * @since 2019/10/14 15:52
	 */
	boolean removeProductTopic(String productId, Topic topic);
}
